<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var num1 = 0.1;
        var num2 = 0.2;

        console.log(num1 + num2);

        // 变量.toFixed(保留小数点后边的位数);

        var res = num1+num2;
        // 0.300000004  => 0.30 
        console.log(res.toFixed(2))


        console.log((num1 * 10 + num2 * 10)/10)

    </script>
</body>
</html>